package com.spark.jta;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;
import javax.transaction.Transactional;

@org.springframework.stereotype.Service
public class Service {
    @Autowired
    private Repository repository;

    @Autowired
    private JdbcTemplate primaryJdbcTemplate;

    @Autowired
    private JdbcTemplate secondJdbcTemplate;

    @Transactional
    public String saveData() {
        String name = "spark";
        repository.save(name, primaryJdbcTemplate);
        repository.save(name, secondJdbcTemplate);
        //int a = 1 / 0;
        return name;
    }
}
